<?php

defined( '_JEXEC' ) or die( 'Restricted access' );

$session        = & JFactory::getSession();

if($session->get('from_dest', '') == 0){
    $begin = booking_helper::get_place_field($session->get('begin', ''), 'title');
}else{
    $begin = $session->get('begin', '');
}		
if($session->get('to_dest', '') == 0){
    $end = booking_helper::get_place_field($session->get('end', ''), 'title');
}else{
    $end = $session->get('end', '');
}

?>

<script type="text/javascript">

function Disab() 

{

    frm=document.getElementById('book_taxi3');

    if(frm.cbox.checked) 

    {

        frm.submit.disabled=false;

        frm.submit.className="buttons";

    }

    else 

    {

        frm.submit.disabled=true;

        frm.submit.className="disable_input";

    }

}

function DisabCash() 

{

    frm=document.getElementById('book_taxi3');

    if(frm.cbox.checked) 

    {

        frm.submitCash.disabled=false;

        frm.submitCash.className="buttons";

    }

    else 	

    {	

        frm.submitCash.disabled=true;	

        frm.submitCash.className="disable_input";	

    }

}

function terms()

{

    var l = (screen.width * .21)

    var t = (screen.height * .09)



    var redURL="termsandconditions.php";

    var EffectiveNewWin = window.open(redURL,'TermsAndConditions','scrollbars=yes,left='+l+',top='+t+',width=700,height=800'); 

}

</script>

<div id="booking" class="booking">

   <form name="book_taxi3" id="book_taxi3" action="<?php echo $this->action ?>" method="post">

        <div class="sized_head">

            <div class="componentheading">

            </div>

            <div class="contenth">

                <br><br>	

                <div id="prev1">
                    <legend style="width: 231px;"><?php echo JText::_(STEP3) ?></legend>
                    <center><u><?php echo JText::_(CHECK_YOUR_ORDER) ?></u></center><hr>
						
                    <div id='prev2' align=center>

                    <?php //echo "php cprice".$cprice;

                    echo '<table border=1 class="bordertable">

                            <tr><td>'.JText::_(NAME).':</td><td>'.$session->get('name', '').' '.$session->get('surname', '').'</td></tr>
                                
                            <tr><td>'.JText::_(GENDER).':</td><td>'.$session->get('title', '').'</td></tr>

                            <tr><td>'.JText::_(EMAIL).':</td><td>'.$session->get('email', '').'</td></tr>

                            <tr><td>'.JText::_(PHONE).':</td><td>'.$session->get('phone', '').'</td></tr>

                            <tr><td>'.JText::_(RETURN_TRIP).':</td><td>'.($session->get('returntrip', 0)?'YES':'NO').'</td></tr>

                            <tr><td>'.JText::_(PRICE).':</td><td>'.$this->elsettings->currency_symbol.''.$session->get('formatted_price', '').'</td></tr>

                            <!--<tr><td>'.JText::_(PREPAYMENT).':</td><td>'.$session->get('prepay', '') .'% ('.($session->get('prepay', '')*$session->get('cprice', '')/100).'  '.$this->elsettings->currency_symbol.')</td></tr>-->

                            <tr><td>'.JText::_(VEHICLE_TYPE).':</td><td>'.booking_helper::getvehicletype($session->get('vehicletype', '')).'</td></tr>



                            <tr><td>'.JText::_(FROM).':</td><td>'.$begin.'</td></tr>';

                    //if($session->get('from_dest' ) != 1){

                        echo '<tr><td>'.booking_helper::AddressType($session->get('from_dest', ''), 1).':</td><td>'.$session->get('PickupAddr1', '').'</td></tr>';

                    if($session->get('from_dest' ) == 1){
                        echo  '<tr><td>'.booking_helper::AddressType($session->get('from_dest', ''), 2).':</td><td>'.$session->get('PickupAddr2', '').'</td></tr>

                            <tr><td>'.booking_helper::AddressType($session->get('from_dest', ''), 3).':</td><td>'.$session->get('PickupAddr3', '').'</td></tr>';
                    }

                      

                            $insuf_time = 0;
           $restrict_time = $this->elsettings->restrict_time;
            $restrict_time = round($restrict_time*60);
                            if ( (booking_helper::DateTime2($session->get('date1', ''), $session->get('time1', '')) - gmdate("YmdHi")) < $restrict_time)

                            {

                                    $insuf_time = 1;

                                    echo '<tr><td>'.JText::_(DATE).':</td><td><font color="#ff0000">'.$session->get('date1', '').' '. $session->get('time1', '').' ('.JText::_(INSUFFICIENT_TIME).')</font></td></tr>';

                            }

                            else echo '<tr><td>Date:</td><td>'.$session->get('date1', '') .' '.$session->get('time1', '').'</td></tr>';



                            echo '<tr><td>'.JText::_(TO).':</td><td>'.$end.'</td></tr>';

                     //if($session->get('to_dest' ) != 1){

                      echo '<tr><td>'.booking_helper::AddressType($session->get('to_dest', ''), 1).':</td><td>'.$session->get('PickupAddr4', '').'</td></tr>';
                     if($session->get('to_dest' ) == 1){ 
                         echo '<tr><td>'.booking_helper::AddressType($session->get('to_dest', ''), 2).':</td><td>'.$session->get('PickupAddr4', '').'</td></tr>';
                         echo '<tr><td>'.booking_helper::AddressType($session->get('to_dest', ''), 3).':</td><td>'.$session->get('PickupAddr4', '').'</td></tr>';
                     }
                            
                     //}


                            if ($session->get('returntrip', ''))

                            if ( ((booking_helper::DateTime2($session->get('date2', ''), $session->get('time2', '')) - booking_helper::DateTime2($session->get('date1', ''), $session->get('time1', '')))) < 0)

                            {

                                    $insuf_time = 1;

                                    echo '<tr><td>'.JText::_(DATE_RETURN_TRIP).':</td><td><font color="#ff0000">'.$session->get('date2', '').' ' .$session->get('time2', '') .'('.JText::_(INSUFFICIENT_TIME).')</font></td></tr>';

                            }

                            else echo '<tr><td>'.JText::_(DATE_RETURN_TRIP).':</td><td>'.$session->get('date2', '') .' '.$session->get('time2', '').'</td></tr>';



                            echo '<tr><td>'.JText::_(MESSAGE).':</td><td>'.$session->get('message', '').'</td></tr>

                        </table>';

                    ?>	

                    </div>

                    <div id='prev3'>
					<hr/>
                                        <a class="editdetail" href="javascript:history.go(-1);"><?php echo JText::_(EDIT_PERSONAL_DETAILS) ?></a>

           <?php		

	if ($insuf_time == 1) echo "<br><b><font color='#ff0000'>".JTEXT::_("CHECK_TIME_AGAIN")."</font></b>";

	else 	//echo "fff cprice".$cprice;	

	echo '  <input type="hidden" name="title" value="'.$session->get("title", "").'" />

                <input type="hidden" name="name" value="'.$session->get('name', '').'" />

                <input type="hidden" name="surname" value="'.$session->get('surname', '').'" />

                <input type="hidden" name="email" value="'.$session->get('email', '').'" />

                <input type="hidden" name="phone" value="'.$session->get('phone', '').'" />

                <input type="hidden" name="from_dest" value="'.$session->get('from_dest', '').'" />

                <input type="hidden" name="to_dest" value="'.$session->get('to_dest', '').'" />

                <input type="hidden" name="returntrip" value="'.$session->get('returntrip', '').'" />

                <input type="hidden" name="cprice"  value="'.$session->get('cprice', '').'" />

                <input type="hidden" name="prepay"  value="'.$session->get('prepay', '').'" />

                <input type="hidden" name="selpsg" value="'.$session->get('selpsg', '').'" />

                <input type="hidden" name="suitcases" value="'.$session->get('suitcases', '').'" />

                <input type="hidden" name="infantseats" value="'.$session->get('infantseats', '').'" />

                <input type="hidden" name="chseats" value="'.$session->get('chseats', '').'" />

                <input type="hidden" name="boosterseats" value="'.$session->get('boosterseats', '').'" />

                <input type="hidden" name="selcarry" value="'.$session->get('selcarry', '').'" />

                <input type="hidden" name="vehicletype" value="'.$session->get('vehicletype', '').'" />

                <input type="hidden" name="PickupAddr1" value="'.$session->get('PickupAddr1', '').'" />

                <input type="hidden" name="PickupAddr2" value="'.$session->get('PickupAddr2', '').'" />

                <input type="hidden" name="PickupAddr3" value="'.$session->get('PickupAddr3', '').'" />

                <input type="hidden" name="PickupAddr4" value="'.$session->get('PickupAddr4', '').'" />

                <input type="hidden" name="PickupAddr5" value="'.$session->get('PickupAddr5', '').'" />

                <input type="hidden" name="PickupAddr6" value="'.$session->get('PickupAddr6', '').'" />

                <input type="hidden" name="date1" value="'.$session->get('date1', '').'" /> 

                <input type="hidden" name="date2" value="'.$session->get('date2', '').'" />

                <input type="hidden" name="time1" value="'.$session->get('time1', '').'" />

                <input type="hidden" name="time2" value="'.$session->get('time2', '').'" />

                <input type="hidden" name="message" value="'.$session->get('message', '').'" />

                <input type="hidden" name="begin" value="'.$session->get('begin', '').'" />

                <input type="hidden" name="end" value="'.$session->get('end', '').'" />';		

        

        

        if($session->get('submittype') == 'Submitpaypal'){

            echo "<label for 'test'>

                <input name='cbox' class='checkb0' value='".JText::_(TERMS_CONDITION)."' onclick='Disab();' type='checkbox'>

               ".JText::_(PLEASE_CHECK_TO_ACCEPT)."</label> <a href='javascript:terms();'>".JText::_(TERMS_CONDITION)."</a><br><br>

                <font color='#ff0000'><i><b>*".JText::_(WHEN_PAYMENT_FINISHED).".</b></i></font><br><br>

                <input id='test' name='submit' value='".JText::_(MAKE_BOOKING)."' type='submit' title='".JText::_(MAKE_BOOKING)."' class='disable_input' disabled>";

        }

   if($session->get('submittype') == 'Submitncipay'){

            echo "<label for 'test'>

                <input name='cbox' class='checkb0' value='".JText::_(TERMS_CONDITION)."' onclick='Disab();' type='checkbox'>

                ".JText::_(PLEASE_CHECK_TO_ACCEPT)."</label> <a href='javascript:terms();'>".JText::_(TERMS_CONDITION)."</a><br><br>

                <input id='test' name='submit' value='Make a booking' type='submit' title='Make a booking' class='disable_input' disabled>";

        }
 if($session->get('submittype') == 'Submitanzpay'){

            echo "<label for 'test'>

                <input name='cbox' class='checkb0' value='".JText::_(TERMS_CONDITION)."' onclick='Disab();' type='checkbox'>

                ".JText::_(PLEASE_CHECK_TO_ACCEPT)."</label> <a href='javascript:terms();'>".JText::_(TERMS_CONDITION)."</a><br><br>

                <input id='test' name='submit' value='Make a booking' type='submit' title='Make a booking' class='disable_input' disabled>";

        }
        if($session->get('submittype') == 'SubmitCash'){

            $code = generateCode(5);

            $session->set('security_code', $code);

            

            echo "<input type='hidden' name='orderdate' value='".$session->get('date1', '')."' /> 

                <input type='hidden' name='orderdatereturn' value='".$session->get('date2', '')."' /> 

            <label for 'test'><input name='cbox' class='checkb0' value='".JText::_(TERMS_CONDITION)."' onclick='DisabCash();' type='checkbox'>

                ".JText::_(PLEASE_CHECK_TO_ACCEPT)."</label> <a href='javascript:terms();'>".JText::_(TERMS_CONDITION)."</a>

                <br>
				<label for='security_code'>".JText::_(CAPTCHA).": </label><br>
                <img src='".JURI::base()."components/com_taxibooking/helpers/captchaSecurityImages.php?code=".$code."&width=100&height=40&characters=5' />&nbsp&nbsp&nbsp<input id='security_code' style=\"margin-top: -16px;\" name='security_code' type='text' maxlength='5' />

                

                <br>".$session->get('security_code_error', '')."<br>

                <input id='test' name='submitCash' value='".JText::_(MAKE_BOOKING)."' type='submit' title='".JText::_(MAKE_BOOKING)."' class='disable_input' disabled>

            ";

        }

          

?>
</div>

                </div>



                <br>

     

                    <br>

            </div>

            <b class="b4bh"></b>	

            <b class="b3bh"></b>	

            <b class="b2bh"></b>	

            <b class="b1h"></b>

    </div>

       

       <?php echo JHTML::_( 'form.token' ); ?>

       <input type="hidden" name="option" value="com_taxibooking" />

    <input type="hidden" name="task" value="submitOrder" />

    </form>

</div>



<?php

function generateCode($characters) 

{

        /* list all possible characters, similar looking characters and vowels have been removed */

        $possible = '23456789bcdfghjkmnpqrstvwxyz';

        $code = '';

        $i = 0;

        while ($i < $characters) { 

                $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);

                $i++;

        }

        return $code;

}

?>